package br.com.cicero.notasfiscais.mb;

import java.util.ArrayList;
import java.util.List;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.ViewScoped;

import org.primefaces.model.LazyDataModel;

import br.com.cicero.notasfiscais.dao.DAO;
import br.com.cicero.notasfiscais.datamodel.DataModelNotasFiscais;
import br.com.cicero.notasfiscais.modelo.NotaFiscal;

@ManagedBean
@ViewScoped
public class ListaNotasFiscaisBean {
	
	private LazyDataModel<NotaFiscal> dataModel;
	private List<NotaFiscal> notas;
	
	public ListaNotasFiscaisBean() {
		
		this.dataModel = new DataModelNotasFiscais();
		
		DAO<NotaFiscal> dao = new DAO<NotaFiscal>(NotaFiscal.class);
		this.dataModel.setRowCount(dao.contaTodas());
		this.dataModel.setPageSize(5);
		
	}
		
	
	public List<NotaFiscal> getNotas() {
		
		 notas = new ArrayList<NotaFiscal>();
		 DAO<NotaFiscal> dao = new DAO<NotaFiscal>(NotaFiscal.class);
		 notas = dao.listaTodos(); 
			
		return notas;
	}
	
	public LazyDataModel<NotaFiscal> getDataModel() {
		return dataModel;
	}
	
	
}
